from typing import Mapping


def merge_dicts(*dicts: Mapping) -> dict:
    """ Recursively merges dictionaries """
    if len(dicts) == 0:
        return {}
    elif len(dicts) == 1:
        return dict(dicts[0])
    elif len(dicts) > 2:
        return merge_dicts(merge_dicts(dicts[0], dicts[1]), *dicts[2:])

    dr = {}
    d1, d2 = dicts
    for k in d1.keys() | d2.keys():
        if k in d1 and k in d2:
            if isinstance(d1[k], dict) and isinstance(d2[k], dict):
                dr[k] = merge_dicts(d1[k], d2[k])
            else:
                dr[k] = d2[k]
        elif k in d1:
            dr[k] = d1[k]
        else:
            dr[k] = d2[k]
    return dr
